
public class VowelReplacement {
    public boolean checkForVowelPercent(String givenString) {
        float vowelCount = 0 ;
        float thirtyPercent = 0.3f;
        for (int count = 0; count < givenString.length(); count++)
            if (checkIfCharIsVowel(givenString.toLowerCase().charAt(count))) {

                vowelCount++;

            }
        return vowelCount / givenString.length() > thirtyPercent;

    }

    public boolean checkIfCharIsVowel(char givenChar) {

        if (givenChar == 'a' || givenChar == 'e' || givenChar == 'i' || givenChar == 'o' || givenChar == 'u')
            return true;
        return false;

    }

    public String replaceWithMommy(String givenString) {

        String outputString = "";
        if (checkForVowelPercent(givenString)) {
            boolean vowelAlreadyReplaced = false;

            for (int count = 0; count < givenString.length(); count++) {
                if (checkIfCharIsVowel(givenString.toLowerCase().charAt(count))) {
                    if (!vowelAlreadyReplaced) {
                        outputString += "mommy";
                        vowelAlreadyReplaced = true;
                    } else {
                        outputString += "";
                        vowelAlreadyReplaced = true;
                    }
                } else

                {
                    outputString += givenString.charAt(count);
                    vowelAlreadyReplaced = false;
                }
            }

        }
        return outputString;
    }


}